<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    var str='hello world 我爱你！'
    function fun(str){
        var arr=str.split('')
        var list=arr.reverse()//字符串反转
        var jion=list.join('')

        return jion

        if(typeof str==='string'){
            return str.split(' ').join('')//去除空格
        }

        newStr=str.slice(0,1).toUpperCase()+str.slice(1).toLowerCase()
        return newStr//首字母转大写
        var a=str.replace("d","D")
        console.log(a)
    }

    fun(str)
    console.log(fun(str))
</script>
</html>